package com.office.stacks.circumstance.service.impl;

import java.util.List;

import com.office.common.utils.DateUtils;
import com.office.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.office.stacks.circumstance.mapper.CircumstanceMapper;
import com.office.stacks.circumstance.domain.Circumstance;
import com.office.stacks.circumstance.service.ICircumstanceService;

/**
 * 任务情况Service业务层处理
 *
 * @author 柒月
 * @date 2025-05-24
 */
@Service
public class CircumstanceServiceImpl implements ICircumstanceService {

    @Autowired
    private CircumstanceMapper circumstanceMapper;

    /**
     * 查询任务情况
     *
     * @param id 任务情况主键
     * @return 任务情况
     */
    @Override
    public Circumstance selectCircumstanceById(Long id)
    {
        return circumstanceMapper.selectCircumstanceById(id);
    }

    /**
     * 查询任务情况列表
     *
     * @param circumstance 任务情况
     * @return 任务情况
     */
    @Override
    public List<Circumstance> selectCircumstanceList(Circumstance circumstance) {

        // 获取当前登录用户
        Long loginUserId = SecurityUtils.getUserId();

        return circumstanceMapper.selectCircumstanceList(circumstance,loginUserId);
    }

    /**
     * 新增任务情况
     *
     * @param id 打回任务id
     * @return 结果
     */
    @Override
    public int callCircumstance(Long id) {
        return circumstanceMapper.callCircumstance(id);
    }

    /**
     * 修改任务情况
     *
     * @param circumstance 任务情况
     * @return 结果
     */
    @Override
    public int updateCircumstance(Circumstance circumstance)
    {
        circumstance.setUpdateTime(DateUtils.getNowDate());
        return circumstanceMapper.updateCircumstance(circumstance);
    }

    /**
     * 批量删除任务情况
     *
     * @param ids 需要删除的任务情况主键
     * @return 结果
     */
    @Override
    public int deleteCircumstanceByIds(Long[] ids)
    {
        return circumstanceMapper.deleteCircumstanceByIds(ids);
    }
}
